clear
cap log close

cd "D:\Dropbox\Work\Research\CreditCardABSRewrite\Draft\ReplicationFiles\Tab_6"

local today = "`c(current_date)'"
log using "Table_06_Log.log", text append

import delimited "Data_Table_06.csv"

* generate indicators for subperiods
generate pre=1 if year<2007
generate cri=1 if year>2006 & year<2010
generate post=1 if year>2009 & year<2021

* Table 10

*****************
* A Tranche
* All
regress portfyld riskprem_a  chargeoff_1m mpr i.year, vce(cluster year) 
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons label title("A Tranche") ctitle("All") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word slow(100) replace

* 2000-2006
regress portfyld riskprem_a  chargeoff_1m mpr i.year if pre==1, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons label title("A Tranche") ctitle("2000-2006") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100) word 

* 2007-2009
regress portfyld riskprem_a  chargeoff_1m mpr i.year if cri==1, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons label title("A Tranche") ctitle("2007-2009") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100)  word

* 2010-2020
regress portfyld riskprem_a  chargeoff_1m mpr i.year if post==1, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons label title("A Tranche") ctitle("2010-2020") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100)  word


*******************
* B Tranche
* All
regress portfyld riskprem_b chargeoff_1m mpr i.year, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons label title("B Tranche") ctitle("All") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word slow(100)  replace

* 2000-2006
regress portfyld riskprem_b chargeoff_1m mpr i.year if pre==1, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons label title("B Tranche") ctitle("2000-2006") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100)  word

* 2007-2009
regress portfyld riskprem_b chargeoff_1m mpr i.year if cri==1, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons label title("B Tranche") ctitle("2007-2009") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100)  word

* 2010-2020
regress portfyld riskprem_b chargeoff_1m mpr i.year if post==1, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons label title("B Tranche") ctitle("2010-2020") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100)  word


*******************
* C Tranche
* All
regress portfyld riskprem_c chargeoff_1m mpr i.year, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster adjr2 nocons label title("C Tranche") ctitle("All") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word slow(100) replace

* 2000-2006
regress portfyld riskprem_c chargeoff_1m mpr i.year if pre==1, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster  adjr2 nocons label title("C Tranche") ctitle("2000-2006") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100) word

* 2007-2009
regress portfyld riskprem_c chargeoff_1m mpr i.year if cri==1, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster adjr2 nocons label title("C Tranche") ctitle("2007-2009") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100) word

* 2010-2020
regress portfyld riskprem_c chargeoff_1m mpr i.year if post==1, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster  adjr2 nocons label title("C Tranche") ctitle("2010-2020") drop(i.year portfyld) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) slow(100) word

log close